<?php

class Ingenii_CMS extends Ingenii_Core {
	
	private $config;
	private $conn;
	
	public function __construct() {
		$this->config = Ingenii_Config::getInstance()->base;
		
		//setup database connection
		$dbsettings = $this->config->dbSettings;
		$dsn = sprintf("%s://%s:%s@%s:%s/%s", $dbsettings->protocol, $dbsettings->username, $dbsettings->password, $dbsettings->host, $dbsettings->port, $dbsettings->dbname);
		$this->conn = Doctrine_Manager::connection($dsn);		
		$this->conn->setListener(new Ingenii_DoctrineListener());
	}

	public function run() {		
		// test with resource
		$resource = Resource::getById(5);
		$module = Ingenii_Module::returnModule($resource->module->className, $resource->resourceParameters);
		
		ob_start();
		$module->run();
		$output = ob_get_contents();
		ob_end_clean();
		
		echo $output;
	}
}